package com.ruoyi.web.controller.work;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.work.domain.vo.WorkDataClearRecord;
import com.ruoyi.work.service.IWorkDataClearService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: MMDZ
 * @Desc: TODO 数据清除
 */
@RestController
@RequestMapping("/work/clear")
public class WorkDataClearController extends BaseController {

    @Autowired
    private IWorkDataClearService workDataClearService;

    /**
     * 查询 填报数据
     */
    @PreAuthorize("@ss.hasPermi('work:clear:list')")
    @GetMapping("/list")
    public AjaxResult list(WorkDataClearRecord workDataClearRecord) {
        Integer pageNum = ServletUtils.getParameterToInt(TableSupport.PAGE_NUM);
        Integer pageSize = ServletUtils.getParameterToInt(TableSupport.PAGE_SIZE);
        return AjaxResult.success(workDataClearService.selectFillDataList(workDataClearRecord, pageNum, pageSize));
    }

    /**
     * 删除 填报数据
     */
    @PreAuthorize("@ss.hasPermi('work:clear:list')")
    @Log(title = "删除填报数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/del")
    public AjaxResult remove(@RequestBody WorkDataClearRecord workDataClearRecord) {
        return toAjax(workDataClearService.delete(workDataClearRecord));
    }

    /**
     * 查询 已删除数据
     */
    @PreAuthorize("@ss.hasPermi('work:restore:list')")
    @GetMapping("/delList")
    public AjaxResult delList(WorkDataClearRecord workDataClearRecord) {
        Integer pageNum = ServletUtils.getParameterToInt(TableSupport.PAGE_NUM);
        Integer pageSize = ServletUtils.getParameterToInt(TableSupport.PAGE_SIZE);
        return AjaxResult.success(workDataClearService.selectClearDataList(workDataClearRecord, pageNum, pageSize));
    }

    /**
     * 还原 数据
     */
    @PreAuthorize("@ss.hasPermi('work:restore:list')")
    @Log(title = "还原数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkDataClearRecord workDataClearRecord) {
        return toAjax(workDataClearService.edit(workDataClearRecord));
    }
}
